The following code sample shows how to reference a report formula at runtime using the formula name instead of referencing the formula by index.
You can put this code in the General Declarations.
Dim CRXReport As New CrystalReport1 Dim CRXFormulaFields As CRAXDRT.FormulaFieldDefinitions Dim CRXFormulaField As CRAXDRT.FormulaFieldDefinition
You can put this code in the Form_Load event procedure.
Private Sub Form_Load() Set CRXFormulaFields = CRXReport.FormulaFields
Now you can cycle through the formula fields collection.
For Each CRXFormulaField In CRXFormulaFields
Here you find the formula you require by specifying its name. Note the format that the .Name property returns.
If CRXFormulaField.Name = "{@formula}" Then
CRXFormulaField.Text = "{Customer.Name}" End If Next
Finally, you can view the report.
Crviewer1.ReportSource = CRXReport Crviewer1.ViewReport End Sub
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |